<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }
        html,
        body {
            width: 100%;
            height: 100%;
            border: 1px solid black;
            overflow: hidden;
            box-sizing: border-box;
        }

        .add {
            width: 100%;
            height: 100%;
        }
        #text {
            display: block;
            width: 90%;
            height: 300px;
            border: 1px solid black;
            margin-left: 15px;
        }
    </style>
    <body>
        <div class="add">
            <button id="add">发布</button>
            <textarea name="" id="text" cols="30" rows="10" placeholder="在这里书写内容"></textarea>
        </div>
    </body>

    <script src="./axios.js"></script>
    <script>
        add.onclick = () => {
            if (text.value != '') {
                axios
                    .post('/addtext', {
                        user: localStorage.user,
                        text: text.value,
                    })
                    .then(res => {
                        alert(res.data.msg);
                        location.href = '/home';
                    });
            } else {
                alert('请输入内容');
            }
        };
    </script>
</html>
